'use strict';

const BaseController = require('./base');

class AnnouncementController extends BaseController {
  constructor(ctx) {
    super(ctx, 'announcement');
  }

  // 获取活跃的公告
  async getActiveAnnouncements() {
    const { ctx } = this;
    
    // 查询状态为启用的公告
    const where = { status: 1 };
    
    // 获取公告列表，按置顶和创建时间排序
    const announcements = await ctx.service.announcement.getActiveAnnouncements(where);
    
    ctx.success(announcements);
  }
}

module.exports = AnnouncementController;
